//
//  BLPartyContainController.m
//  Byelone
//
//  Created by Qi Liu on 2021/1/30.
//

#import "BLPartyContainController.h"
#import "BLMeetController.h"
#import "UIButton+Extension.h"
#import "BLInfoPhotosViewController.h"
#import "BLSendMomentController.h"
#import "BLCommonSheet.h"
#import "BLBuyVipController.h"
//测试
#import "BLPartyMomentController.h"

@interface BLPartyContainController ()

@end

@implementation BLPartyContainController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addRightNa];
}
-(void)addRightNa{

    UIButton * right = [UIButton buttonWithType:UIButtonTypeCustom];
    right.frame = CGRectMake(BL_WINDOW_WIDTH - 90, 7, 60, 30);
    [right setTitle:@"发布" forState:UIControlStateNormal];
    [right setImage:[UIImage imageNamed:@"issuance"] forState:UIControlStateNormal];
    [right addTarget:self action:@selector(sendIssuance:) forControlEvents:UIControlEventTouchUpInside];
    right.titleLabel.font = [UIFont systemFontOfSize:15];
    [right setTitleColor:[UIColor chColorWithHexString:@"#555555"] forState:UIControlStateNormal];
    [right layoutButtonWithImageStyle:ZJButtonImageStyleLeft imageTitleToSpace:6];
    [self.navigationItem.titleView addSubview:right];
}

-(void)sendIssuance:(UIButton *)sender{
    NSLog(@"发布");
    [BLCommonSheet show:@[@"视频+文字",@"图片+文字",@"文字动态"] click:^(NSInteger index) {
        NSLog(@"点击了：%ld",index);
        [self sendMomentType:index];
    }];


//    BLBuyVipController * sendVC = [[BLBuyVipController alloc]init];
//
//    [self.navigationController pushViewController:sendVC animated:YES];
//
}

-(void)sendMomentType:(NSInteger)index{
    NSArray *typeArray = @[@(BLComment_Type_Text_Video),@(BLComment_Type_Text_Pic),@(BLComment_Type_Text)];
    BLSendMomentController * sendVC = [[BLSendMomentController alloc]init];
    NSNumber *number = typeArray[index];
    sendVC.sendType = number.integerValue;
    sendVC.sendBack = ^{
        self.selectIndex = 2;
    };
    [self.navigationController pushViewController:sendVC animated:YES];
}


-(NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController{
    return 3.0f;
}
-(NSString *)pageController:(WMPageController *)pageController titleAtIndex:(NSInteger)index{
    switch (index) {
        case 0: return @"生活";
        case 1: return @"喜欢";
        case 2: return @"我的动态";
    }
    return @"NONE";
}

- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index {
    switch (index % 3) {
        case 0: return [BLPartyMomentController createMomentVCWithType:MomentVCType_Life];
        case 1: return [BLPartyMomentController createMomentVCWithType:MomentVCType_Like];
        case 2: return
//            [[NSClassFromString(@"TestController") alloc]init];
            [BLPartyMomentController createMomentVCWithType:MomentVCType_Self];
    }
    return [[UIViewController alloc] init];
}


-(CGFloat)menuView:(WMMenuView *)menu itemMarginAtIndex:(NSInteger)index{
    if (index == 2) {
        return 0;
    }else{
        return -2;
    }
}

- (CGFloat)menuView:(WMMenuView *)menu widthForItemAtIndex:(NSInteger)index {
    if (index == 2) {
        return 100;
    }
    CGFloat width = [super menuView:menu widthForItemAtIndex:index];
    return width ;
}
- (CGRect)pageController:(WMPageController *)pageController preferredFrameForMenuView:(WMMenuView *)menuView {
    CGFloat leftMargin = self.showOnNavigationBar ? 0 :50;
    CGFloat originY = self.showOnNavigationBar ? 0 : CGRectGetMaxY(self.navigationController.navigationBar.frame);
     return CGRectMake(0, originY, self.view.frame.size.width, 44);
}

//内容 下面的各个页面
- (CGRect)pageController:(WMPageController *)pageController preferredFrameForContentView:(WMScrollView *)contentView {
  return CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}


- (UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleDefault;
}
- (BOOL)shouldAutorotate {
    return NO;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}



@end
